package com.example.easypad.ui.home;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;

import com.example.easypad.Notes;
import com.example.easypad.databinding.FragmentHomeBinding;
import com.example.easypad.MyAdapter;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

public class HomeFragment extends Fragment {

    private FragmentHomeBinding binding;

    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        HomeViewModel homeViewModel =
                new ViewModelProvider(this).get(HomeViewModel.class);

        binding = FragmentHomeBinding.inflate(inflater, container, false);
        View root = binding.getRoot();

        //final TextView textView = binding.textHome;
        //homeViewModel.getText().observe(getViewLifecycleOwner(), textView::setText);
//        final ListView lv_notes = binding.lvNotes;
//        homeViewModel.getText().observe(getViewLifecycleOwner(), lv_notes);
//        List<Notes> data = new ArrayList<>();
//        Notes a = new Notes("标题a","内容a","类型1");
//        Notes b = new Notes("标题b","内容b","类型1");
//        Notes c = new Notes("标题c","内容c","类型1");
//        data.add(a);
//        data.add(b);
//        data.add(c);
//        lv_notes.setAdapter(new MyAdapter(data,this));


        return root;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        binding = null;
    }
}